import http from '/src/utils/request'

export function getBlogs(current, size, category,tag) {
  if (!category&&!tag) return http.get(`/plugins/baliServer-module-blog/api/blog/article/list?current=${current}&size=${size}`)
  else if(category&&!tag)
    return http.get(`/plugins/baliServer-module-blog/api/blog/article/list?category=${category}&current=${current}&size=${size}`)
  else if(category&&tag)
    return http.get(`/plugins/baliServer-module-blog/api/blog/article/list?category=${category}&tag=${tag}&current=${current}&size=${size}`)
  else if(!category&&tag)
    return http.get(`/plugins/baliServer-module-blog/api/blog/article/list?tag=${tag}&current=${current}&size=${size}`)
}

export function getBlogDetail(id) {
  return http.get('/plugins/baliServer-module-blog/api/blog/article/' + id)
}

export function pubBlog(form) {
  return http.post('/plugins/baliServer-module-blog/api/blog/article/save', form)
}

export function getUserBlog(current, size, userId) {
  return http.get(`/plugins/baliServer-module-blog/api/blog?current=${current}&size=${size}&userId=${userId}`)
}

export function delBlog(id) {
  return http.delete(`/plugins/baliServer-module-blog/api/blog/${id}`)
}

export function getTagList(current,size){
  return http.get(`/plugins/baliServer-module-blog/api/blog/tag/list?current=${current}&size=${size}`)
}

export function getLeftAsideTagList(){
  return http.get(`/plugins/baliServer-module-blog/api/blog/tag/getLeftAsideFix`)
}

// 翻译单个单词
export function translate(word) {
  return http.get('/api/' + word)
}
